package demo1;

public class Dog {
    //成员变量
    public String name;
    public int age;
    public String gender;

    //成员方法
    public void eat() {
        System.out.println(this.name + "吃狗粮...");
    }
    public void sleep() {
        System.out.println(this.name + "睡觉...");
    }


    //无参构造
    public Dog() {}

    //有参构造
    public Dog(String name, int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public static void main(String[] args) {
        //对象实例化
        Dog dog1 = new Dog("大黄",2,"male");
        Dog dog2 = new Dog();

        dog1.name = "大黄";
        dog1.age = 2;
        dog1.gender = "male";

        dog2.name = "小白";
        dog2.age = 3;
        dog2.gender = "female";

        System.out.println(dog1);
        System.out.println(dog2);
    }
}
